#pragma once

#include <QtWidgets/QWidget>
#include "ui_HelloWebView2.h"
#include <wil/wrl.h>
#include <wil/com.h>
#include <WebView2.h>
#include <QResizeEvent>

class HelloWebView2 : public QWidget
{
    Q_OBJECT

public:
    HelloWebView2(QWidget *parent = nullptr);
    ~HelloWebView2();
	
private:
    Ui::HelloWebView2Class ui;

    wil::com_ptr<ICoreWebView2Controller> webviewController;
    wil::com_ptr<ICoreWebView2> webview;
    EventRegistrationToken processFailedToken = {};
    EventRegistrationToken messageReceivetoken = {};

    void initializeWebView2();
    void reinit();
    void cleanup();
    void resizeEvent(QResizeEvent* event);
    HRESULT messageReceived(ICoreWebView2* webview, ICoreWebView2WebMessageReceivedEventArgs* args);
};
